﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mainmenu="clr-namespace:Peter.Common.MainMenu">

   <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Peter.Common;component/Themes/Common.xaml" />
   </ResourceDictionary.MergedDictionaries>

   <Style TargetType="{x:Type mainmenu:MainMenu}">
      <Setter Property="KeyboardNavigation.TabNavigation"
              Value="Cycle" />
      <Setter Property="KeyboardNavigation.DirectionalNavigation"
              Value="Cycle" />

      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type mainmenu:MainMenu}">
               <Border BorderBrush="{TemplateBinding BorderBrush}"
                       BorderThickness="{TemplateBinding BorderThickness}"
                       Background="{TemplateBinding Background}">
                  <Grid SnapsToDevicePixels="True"
                        ClipToBounds="true"
                        KeyboardNavigation.TabNavigation="Local">

                     <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                     </Grid.RowDefinitions>

                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                     </Grid.ColumnDefinitions>

                     <!-- TAB WELL -->
                     <TabPanel IsItemsHost="True"
                               x:Name="PART_TabPanel"
                               Grid.Column="0"
                               Grid.Row="0" />

                     <!-- QUICK ACCESS TOOL BAR -->
                     <Border Grid.Column="1"
                             Grid.Row="0"
                             Style="{DynamicResource MainMenuQuickAccessAreaStyle}">
                        <mainmenu:MainMenuItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                      Path=QuickAccessMenuItems}"
                                                   Margin="2"
                                                   x:Name="PART_QuickAccess"
                                                   IconSize="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HeaderIconSize}"
                                                   ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                           <mainmenu:MainMenuItemsControl.ItemsPanel>
                              <ItemsPanelTemplate>
                                 <StackPanel Orientation="Horizontal" />
                              </ItemsPanelTemplate>
                           </mainmenu:MainMenuItemsControl.ItemsPanel>
                        </mainmenu:MainMenuItemsControl>
                     </Border>

                     <!-- TAB CONTENT -->
                     <Border Grid.Row="1"
                             Grid.Column="0"
                             Grid.ColumnSpan="2"
                             Style="{DynamicResource MainMenuContentAreaStyle}">
                        <mainmenu:MainMenuItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                      Path=SelectedContent.Children}"
                                                   Margin="2"
                                                   IconSize="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IconSize}"
                                                   ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                           <mainmenu:MainMenuItemsControl.ItemsPanel>
                              <ItemsPanelTemplate>
                                 <WrapPanel />
                              </ItemsPanelTemplate>
                           </mainmenu:MainMenuItemsControl.ItemsPanel>
                        </mainmenu:MainMenuItemsControl>
                     </Border>

                  </Grid>
               </Border>

               <ControlTemplate.Triggers>

                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=QuickAccessMenuItems.Count}"
                                   Value="0" />
                        <Condition Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=QuickAccessMenuItems}"
                                   Value="{x:Null}" />
                     </MultiDataTrigger.Conditions>
                     <Setter TargetName="PART_QuickAccess"
                             Property="Visibility"
                             Value="Collapsed" />
                  </MultiDataTrigger>

               </ControlTemplate.Triggers>

            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

</ResourceDictionary>